﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace FlickrXplorer.Web.Utilities
{
    public class Pager : IDisposable
    {
        private readonly HttpResponseBase response = null;

        public Pager(HtmlHelper helper, string action, string method, object htmlAttributes)
        {
            TagBuilder builder = new TagBuilder("form");


            builder.MergeAttribute("action", action);
            builder.MergeAttribute("method", method);
            builder.MergeAttributes<string, object>(new RouteValueDictionary(htmlAttributes));


            response = helper.ViewContext.HttpContext.Response;
            response.Write(builder.ToString(TagRenderMode.StartTag));
        }

        public void Dispose()
        {
            response.Write("</form>");
        }
    }
}
